async function ${nodeId}(node, index) {
    let debugLoggingLoop = new DebugLogging();
    let logStartTimeLoop = DebugLogging.getTimestamp();
    let logEndTimeLoop;
    node.debugLog.push(debugLoggingLoop);
<#include "common/InitLogging.ftl">
    try {
        let input = ${input};
        let result = await new Promise(async function (resolve, reject) {
            node['${nodeId}'] = [];
            <#list innerNodeIds as innerNodeId>
                <#if innerNodeId != loopEndNodeId>
                    node['${innerNodeId}'] = [];
                </#if>
            </#list>
            if (Array.isArray(input) && input.length > 0) {
                for (let loopIndex = 0; loopIndex < input.length; loopIndex++) {
                    try {
                        node['${nodeId}_' + loopIndex] = input[loopIndex];
                        <#if methodCalls?? && (methodCalls?size > 0)>
                            <#list methodCalls as call>
                                ${call}
                            </#list>
                        </#if>
                    } catch (e) {
                        reject(e);
                        break;
                    }
                }
                <#list innerNodeIds as innerNodeId>
                    <#if innerNodeId != loopEndNodeId>
                        node['${nodeId}'].push(node['${innerNodeId}']);
                    </#if>
                </#list>
                resolve(node['${nodeId}']);
                return node['${nodeId}'];
            } else {
                reject(new Error('for循环的参数必须为数组，并且不能为空数组'));
                return;
            }
        });
        node['${nodeId}'] =
            result;
        node['${loopEndNodeId}'] =
            result;
        debugLoggingLoop.assignOutput(node['${nodeId}']);
        return node['${nodeId}'];
    } catch (e) {
        <#include "common/Catch.ftl">
    } finally {
        logEndTimeLoop = DebugLogging.getTimestamp();
        debugLoggingLoop.assignCommNoOutputParam(${nodeId}, ${nodeType}, '${nodeName}', ${input}, logStartTimeLoop, logEndTimeLoop);
        let debugLoggingEndLoop = new DebugLogging();
        let logStartTimeEndLoop = DebugLogging.getTimestamp();
        let logEndTimeEndLoop = logStartTimeEndLoop;
        node.debugLog.push(debugLoggingEndLoop);
        debugLoggingEndLoop.assignOutput(node['${loopEndNodeId}']);
        debugLoggingEndLoop.assignCommNoOutputParam(${nodeId}, ${loopEndNodeType}, '${loopEndNodeName}', {}, logStartTimeEndLoop, logEndTimeEndLoop);
    }
}

